<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
		<title>订单</title>
		<meta http-equiv="expires" content="0">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<link rel="stylesheet" href="../../../css/reset.css" />
		<link rel="stylesheet" href="../../../css/mui.min.css" />
		<link rel="stylesheet" href="../../../css/iconfont.css" />
		<link rel="stylesheet" href="../../../css/cmms.css" />
		<link rel="stylesheet" href="../../../css/mui.picker.min.css" />
		<link rel="stylesheet" href="../../../css/doctor/order.css" />
	</head>
	<body>
	<div class="mui-content" id="order" v-cloak>
		<div class="search">
			<div class="selectRange">
				<div @tap="selectState">
					{{selState}}<i class="icon iconfont icon-jiantou"></i>
				</div>
			</div>
			<input type="text" placeholder="请输入患者姓名" v-model="patienName"/>
			<span class="btn-primary" @tap='search'>搜索</span>
		</div>
		<div class="wrap" v-show="show">
			<section class="panel order-panel" v-for="o in orderList">
				<div class="overflow order-title">
					<span>{{o.patientName}}</span>
					<span>{{o.submitTime |replaceT}}</span>
					<span class="right"><i class="iconfont icon-shijian-"></i>{{o.orderState+''|formatState}}</span>
				</div>
				<div class="check-server-code check-item" v-if="o.specimenBarCode.length>0">检验条形码：{{o.specimenBarCode.join(',')}}</div>
				<div class="check-item" v-if="o.projectNmae.length>0">{{o.projectNmae.join(',')}}</div>
				<div class="overflow check-item">
					<span>共<span class="basic-color">
						{{o.projectNum}}</span>个检验项目<span class="basic-color"> 
							¥{{o.amount}}</span></span>
					<span class="right"><i class="iconfont icon-icon1 basic-color"></i>{{o.doctorName}}</span>
				</div>
				<div class="overflow get-report">
					<span v-if='o.orderState==4||o.orderState==8||o.orderState==11' @tap="pdf(o.orderId)"><i class="iconfont icon-pdf basic-color"></i>PDF报告</span>
					<span class="btn-detail right" @tap="orderDetail(o.orderId)">订单详情</span>
					<span class="btn-detail right cancelOrder" v-if='o.orderState==1' @tap="del(o.orderId)">取消订单</span>
				</div>
			</section>
		</div>
		<!--未找到数据-->
		<div class="notFind" v-show="!show">
			<img src="../../../img/notFind.png" alt="未找到对应的数据" />
			<p>暂无数据</p>
		</div>
	</div>
		<script src="../../../js/mui.min.js"></script>
		<script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
		<script src="../../../js/mui.picker.min.js"></script>
		<script src="../../../js/vue.js"></script>
		<script src="../../../js/cmms.js?time=333"></script>
		<script>
			new Vue({
				el:"#order",
				data:{
					orderList:[],
					patienName:'',
					selState:'全部',
					selStateNum:'',
					show:false,
					urlArr:[],//报告地址
				},
				mounted(){
					this.init();
					this.getOrderList();
				},
				methods:{
					init(){
						let _this=this;
						/*调用微信接口配置location.href.split('#')[0]*/
						AT.muiAjaxDoctor('/partner-sale/partnerSale/wxConfig','post',{url:location.href.split('#')[0]},function(res){
							wx.config({
								//debug: true,
								appId:res.appId,
								timestamp:res.timestamp,
								nonceStr:res.nonceStr,
								signature:res.signature,
								jsApiList:['previewImage']
							});
						});
					},
					getOrderList(){
						let _this = this;
						AT.muiAjaxDoctor('/clinic-doctor/order/getDoctorOrder','post',{
							name:_this.patienName,
							orderState:_this.selStateNum
						},function(res){
							console.log(res)
							_this.orderList = res;
							if(_this.orderList.length>0){
								_this.show=true;
							}else{
								_this.show=false;
							}
						})
					},
					//查看PDF
					pdf(id){
						let _this = this;
						AT.muiAjaxDoctor('/clinic-doctor/order/getOrderReportByOrderId','post',{id},function(res){
							console.log(res)
							if(res.length==0){
								mui.alert('报告未出');
							}else{
								let pdfId=res;
								for(let i of pdfId){
									let url='https://api.lis.ulabcare.com/api/common/common/downLoadFile?type=0&fileName=1&attachId='+i;
									_this.urlArr.push(url);
								}
								console.log(_this.urlArr);
								_this.getImg();
							}
						})
					},
					
					//根据姓名搜索
					search(){
						this.getOrderList(this.patienName);
					},
					orderDetail(id){
						location.href = "../orderDetail.html?id="+id;
					},
					/*取消订单*/
					del(id){
						console.log(id)
						let _this = this;
						let flag = localStorage.getItem('roamFlag');
						console.log(flag);
						if(flag=='true'){
							mui.alert('您无权限操作！');
						}else{
							mui.confirm("确定要取消这条订单么？",'取消订单',['再考虑一下','取消订单'],function(con){
								if(con.index===1){
									AT.muiAjaxDoctor('/partner-sale/order/delOrderStateById','post',{id},function(res){
										mui.toast(res)
										const timer = setTimeout(() =>{                    
											location.reload();              
										}, 1000);  
										_this.$once('hook:beforeDestroy', () => {            
										    clearTimeout(timer);                                    
										});
									})
								}
							})
						}
					},
					/*状态选择*/
					selectState:function(){
						let _this = this;
						var picker = new mui.PopPicker();
						picker.setData([
							{value:'',text:'全部'},
							{value:'1',text:'未支付'},
							{value:'5',text:'支付中'},
							{value:'13',text:'已支付'},
							{value:'9',text:'送检中'},
							{value:'10',text:'检验中'},
							{value:'11',text:'生成报告'},
							{value:'12',text:'已取消'}
						]);
						picker.show(function (selectItems) {
						    _this.selState=selectItems[0].text;
						    _this.selStateNum=selectItems[0].value;
						    _this.getOrderList();
						})
					},
				}
			})
		</script>
	</body>
</html>

